<?php 
//
// phpCAS client that handles central logout requests from the CAs server
//

// import phpCAS lib
include_once('cas/CAS.php');


// 设置日志
phpCAS::setDebug('');

// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'uuap.baidu.com',443,'',true,'https://uuap.baidu.com/login');
// for production
//phpCAS::client(CAS_VERSION_2_0,'uuap.baidu.com',443,'');

// no SSL validation for the CAS server ，不进行SSL票据验证
phpCAS::setNoCasServerValidation();

// handle incoming logout requests
// enable any server send logout request (that means anyone may send request make your user logout)
phpCAS::handleLogoutRequests(false);
// for production
//phpCAS::handleLogoutRequests(true, array('jx-iit-uuap00.jx.baidu.com', 'jx-iit-uuap01.jx.baidu.com', 'jx-iit-uuap02.jx.baidu.com'));

// force CAS authentication 本地认证
phpCAS::forceAuthentication();

// logout if desired
if (isset($_REQUEST['logout'])) {
    setcookie('username', 'guest', time() + 3600 * 24 * 100, "/");
    phpCAS::logout();
}else{
	// force CAS authentication 本地认证
        phpCAS::forceAuthentication();
        setcookie('username', phpCAS::getUser(), time() + 3600 * 24 * 100, "/");
        header('Location: arch/home');
}

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Arch之窗</title>

<meta name="description" content="KS op" />
<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="resources/css/xtheme-gray.css" />
<link rel="stylesheet" type="text/css" href="resources/docs.css" />
<link rel="stylesheet" type="text/css" href="resources/style.css" />    
<link rel="stylesheet" type="text/css" href="resources/ks-op.css" />    
<link rel="stylesheet" type="text/css" href="resources/css/Spinner.css" />    
<link rel="icon" href="resources/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="resources/favicon.ico" type="image/x-icon" /> 
<style type="text/css"></style>
<!-- GC -->
<script type="text/javascript" src="resources/ext-base.js"></script>
<script type="text/javascript" src="resources/ext-all.js"></script>
<script type="text/javascript" src="resources/TabCloseMenu.js"></script>
<script type="text/javascript" src="resources/DateTimeField.js"></script>
<script type="text/javascript" src="resources/Spinner.js"></script>
<script type="text/javascript" src="resources/SpinnerField.js"></script>
<script type="text/javascript" src="resources/ks-op.js"></script>
<?php 
	$this->load->model('permission');
	$role = $this->permission->getRole($_COOKIE['username']);
	if( $role == 'op') {
		echo '<script type="text/javascript" src="resources/docs-op.js"></script>';
	}else {
		echo '<script type="text/javascript" src="resources/docs.js"></script>';
	}
?>
<script type="text/javascript" src="resources/output/tree.js"></script>
<script type="text/javascript" src="resources/ext-lang-zh_CN.js"></script>
</head>
<body scroll="no" id="docs">
<div id="loading-mask"></div>
<div id="loading">
    <div class="loading-indicator">
        <img src="resources/extanim32.gif" width="32" height="32" style="margin-right:8px;" align="absmiddle" />
        Loading&hellip;
    </div>
</div>

<div id="header">
    <div style="float:right; margin-top: 10px;margin-right: 10px;color: #CCC">
        <a href="#" style="padding:5px">欢迎:<?php echo phpCAS::getUser();?></a> | 
        <div id="feedback">各种功能需求,bug</div>
	<a href="mailto:yujinqiu@baidu.com?cc=ks-op@baidu.com&subject=Aarch之窗[需求 | bug]反馈&body=Hi Ks-Op:" style="padding:5px" onMouseOver="prompt(event)" onMouseOut="document.getElementById('feedback').style.visibility='hidden'">反馈</a> | 
        <a href="" style="padding:5px">帮助</a> | 
        <a href="?logout" style="padding:5px">退出</a>
    </div>
</div>

<div id="classes"></div>

<div id="main"></div>

<select id="search-options" style="display:none">
    <option>Starts with</option>
    <option>Ends with</option>
    <option>Any Match</option>
</select>
</body>
</html>

